spb/wp-spboucher-ai
Public
1import type { Metadata } from "next";2import { notFound } from "next/navigation";3import { getLocale } from "@/lib/i18n/server";4import { t } from "@/lib/i18n";5import { getAuthor, listPapers } from "@/lib/papers/queries";6import { PaperRow } from "@/components/paper-items";7export const revalidate = 300;8export async function generateMetadata({ params }: { params: Promise<{ slug: string }> }): Promise<Metadata> { const { slug } = await params; const a = await getAuthor(slug); return a ? { title: a.display_name, alternates: { canonical: `/authors/${slug}` } } : {}; }9export default async function AuthorPage({ params }: { params: Promise<{ slug: string }> }) {10 const { slug } = await params; const locale = await getLocale(); const d = t(locale); const a = await getAuthor(slug); if (!a) notFound();11 const res = await listPapers({ author: [slug], sort: "recent", perPage: 100 });12 const links: [string, string | null][] = [[d.authors.website, a.website], [d.authors.orcid, a.orcid ? `https://orcid.org/${a.orcid}` : null], [d.authors.scholar, a.google_scholar], [d.authors.ssrn, a.ssrn_url], [d.authors.github, a.github]];13 return (<div className="container py-10"><div className="grid gap-8 lg:grid-cols-[1fr_18rem]"><div><p className="kicker">{d.papers.author}</p><h1 className="text-3xl sm:text-4xl mt-2">{a.display_name}</h1>14 {(locale === "fr" ? a.affiliation_fr : a.affiliation_en) && <p className="text-fg-2 mt-2">{locale === "fr" ? a.affiliation_fr : a.affiliation_en}{(locale === "fr" ? a.department_fr : a.department_en) ? ` · ${locale === "fr" ? a.department_fr : a.department_en}` : ""}</p>}15 {(locale === "fr" ? a.bio_fr : a.bio_en) && <p className="mt-4 text-fg-2 leading-relaxed max-w-3xl">{locale === "fr" ? a.bio_fr : a.bio_en}</p>}16 <p className="meta mt-6">{res.total} {res.total === 1 ? d.topics.paper : d.authors.papers}</p><div className="card px-5 mt-3">{res.items.map((p) => <PaperRow key={p.id} p={p} locale={locale} />)}</div></div>17 <aside className="card p-4 text-sm self-start"><ul className="space-y-2">{links.filter(([, v]) => v).map(([k, v]) => <li key={k}><span className="label block">{k}</span><a href={v!} rel="me noopener" className="text-navy break-all">{v}</a></li>)}{a.email && <li><span className="label block">E-mail</span><a href={`mailto:${a.email}`} className="text-navy">{a.email}</a></li>}</ul></aside></div></div>);18}19